package Problem;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

/**
 * Creat with IntelliJ IDEA
 * Description:单选题题库
 * Date:2021-12-14
 * Time:4:40
 */
public class Single_choice_question implements Problem{
    private Question[] s;
    private int[] usage = new int[10];

    public Single_choice_question() throws FileNotFoundException {
        s = new Question[10];
        File file = new File("E:\\方秋慧\\JAVA程序设计\\单选.txt");
        Scanner scanner = new Scanner(file);
        try {
            for (int i = 0; i < 10; i++) {
                scanner.useDelimiter("[、\n]");
                int number = Integer.valueOf(scanner.next());
                String q = scanner.nextLine().substring(1);
                String[] choice = new String[4];
                for (int j = 0; j < 4; j++) {
                    choice[j] = scanner.nextLine();
                }
                String answer = scanner.nextLine();
                s[i] = new Question(number,q,choice,answer);
            }
        }catch (Exception exp){
            System.out.println(exp);
        }

    }

    public Question[] getS() {
        return s;
    }

    public void setS(Question[] s) {
        this.s = s;
    }

    public int getUsage(int num) {
        return usage[num];
    }

    public void setUsage(int num) {
        this.usage[num] = 1;
    }

    @Override
    public Question question(int number) {
        return s[number];
    }

    @Override
    public void display() {
        for (Question s:s) {
            System.out.println(s);
            System.out.println();
        }
    }

    public static void main(String[] args) {
        try {
            Single_choice_question scq = new Single_choice_question();
            scq.display();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
